const adminModel = require("../models/admin_model")
const Result = require("../beans/result")

const {
    createToken
} = require("../beans/token")
function doAdminLogin(admin,msg,callback) {
    
    adminModel.getAdmin(admin, (err, data) => {
        if (err) {
            callback(new Result(err, null, msg[0], 401))
        } else {
            const token = createToken({}, 10)
            callback(new Result(null, {Authorization:token,username:admin.username}, msg[1], 200))
        }
    })
}

module.exports = {
    doAdminLogin,
}